home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / strstream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-02  |  3.4 KB  |  153 lines

  1. #if __SC__ || __RCC__
  2. #pragma once
  3. #endif
  4.  
  5. #ifndef _STRSTREAM_H_
  6. #define _STRSTREAM_H_
  7.  
  8. #ifndef __cplusplus
  9. #error  Use C++ compiler for strstrea.h
  10. #endif
  11.  
  12. /*
  13.  *    strstream.h -- class strstream declarations
  14.  *
  15.  * $Id: strstrea.h,v 1.1.1.1 1997/01/02 19:16:44 smarx Exp $
  16.  *
  17.  ****************************************************************************
  18.  *
  19.  * Rogue Wave Software, Inc.
  20.  * P.O. Box 2328
  21.  * Corvallis, OR 97339
  22.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  23.  *
  24.  * Copyright (C) 1991,  1993, 1994.
  25.  * This software is subject to copyright protection under the laws of 
  26.  * the United States and other countries.
  27.  * ALL RIGHTS RESERVED
  28.  *
  29.  ***************************************************************************
  30.  *
  31.  * $Log: strstrea.h,v $
  32.  * Revision 1.1.1.1  1997/01/02 19:16:44  smarx
  33.  * cafe12
  34.  *
  35. // * 
  36. // * 5     2/26/96 8:05a Smarx
  37.  * 
  38.  *    Rev 1.3   24 May 1995 15:42:34   Andrew
  39.  * Fixed problem where structs/classes were not in pragma pack(__DEFALIGN)
  40.  * 
  41.  *    Rev 1.2   08 Oct 1994 14:11:54   BUSHNELL
  42.  * Added pragma once for faster compilations
  43.  * 
  44.  *    Rev 1.1   02 Jun 1994 21:35:44   bushnell
  45.  * added ifdef so that MS RC will not include header twice
  46.  * 
  47.  
  48.  *    Rev 1.0   28 Apr 1994 19:19:44   thompson                   
  49.  
  50.  * Initial revision.
  51.  
  52.  * 
  53.  
  54.  *    Rev 1.0   20 Apr 1994 17:46:36   thompson                   
  55.  
  56.  * Initial revision.
  57.  
  58.  * Revision 1.1  1994/04/14  16:57:40  vriezen
  59.  * Initial revision
  60.  *
  61.  * Revision 1.2  1994/04/14  00:50:17  vriezen
  62.  * Updated copywrite, added ID and LOG and changed comments to indicate .cpp filename
  63.  *
  64.  *
  65.  * 
  66.  */
  67.  
  68.  
  69. #include <iostream.h>
  70.  
  71. #pragma pack(__DEFALIGN)
  72.  
  73. class strstreambuf : public streambuf {
  74. public:
  75.         strstreambuf();
  76.         strstreambuf(int n);
  77.         strstreambuf(void* (*a)(long), void (*f)(void*));
  78.         strstreambuf(char* _s, int, char* _strt=0);
  79.         ~strstreambuf();
  80.  
  81.     void    freeze(int = 1);
  82.     int    isfrozen();
  83.     char*    str();
  84. virtual int    doallocate();
  85. virtual int    overflow(int);
  86. virtual int    underflow();
  87. virtual streambuf* setbuf(char*, int);
  88. virtual streampos seekoff(streamoff, ios::seek_dir, int);
  89.  
  90. private:
  91.     void*    (*allocf)(long);
  92.     void    (*freef)(void*);
  93.     short    ssbflags;
  94.     enum    { dynamic = 1, frozen = 2, unlimited = 4 };
  95.     int    next_alloc;
  96.     char*    real_end;
  97.  
  98.     void    init(char*, int, char*);
  99. };
  100. inline int strstreambuf::isfrozen() { return (ssbflags&frozen) != 0; }
  101.  
  102.  
  103. class strstreambase : public virtual ios {
  104. public:
  105.     strstreambuf* rdbuf();
  106.  
  107. protected:
  108.         strstreambase(char*, int, char*);
  109.         strstreambase();
  110.         ~strstreambase();
  111. private:
  112.     strstreambuf buf;
  113. };
  114. inline strstreambuf* strstreambase::rdbuf() { return &this->buf; }
  115.  
  116.  
  117. class istrstream : public strstreambase, public istream {
  118. public:
  119.         istrstream(char*);
  120.         istrstream(char*, int);
  121.         ~istrstream();
  122. };
  123.  
  124.  
  125. class ostrstream : public strstreambase, public ostream {
  126. public:
  127.         ostrstream(char*, int, int = ios::out);
  128.         ostrstream();
  129.         ~ostrstream();
  130.  
  131.     char*    str();
  132.     int    pcount();
  133. };
  134. inline char*    ostrstream::str() { return strstreambase::rdbuf()->str(); }
  135. inline int    ostrstream::pcount() {
  136.             return strstreambase::rdbuf()->out_waiting();
  137.         }
  138.  
  139.  
  140. class strstream : public strstreambase, public iostream {
  141. public:
  142.         strstream();
  143.         strstream(char*, int _sz, int _m);
  144.         ~strstream();
  145.  
  146.     char*    str();
  147. };
  148. inline char* strstream::str() { return strstreambase::rdbuf()->str(); }
  149.  
  150. #pragma pack()
  151.  
  152. #endif /* _STRSTREAM_H_ */
  153.